-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow create upsert actions in state transitions #71
Conversation
Another place that will need to be updated is this code: https://github.com/ash-project/ash_state_machine/blob/main/lib/ash_state_machine.ex#L140 Currently, we just check that the target state is in valid initial states. However, if the action is an upsert action, we now have to look up the valid next states for all transitions for this action and make sure that the given state is in that list. Additionally, we have to ensure at compile time that a state transition listed for an upsert action has all states in its |
Just pushed a commit for a compile time check that I'm having a hard time wrapping my head around this:
Did you mean "we have to look up the valid next states for all transitions for this resource"? In my current understanding each action can have only one transition. If so does that mean we'd need to check for a configuration like this? transitions do
transition(:begin, from: :pending, to: [:executing, :pending])
transition(:complete, from: :executing, to: [:complete, :pending])
transition(:initialize, from: :*, to: :pending)
...
end |
There can be multiple transitions per action. For example, you could have: transition(:begin, from: :pending, to: :executing)
transition(:begin, from: :paused, to: :resumed) This is different than transition(:begin, from: [:pending, :paused], to: [:executing, :resumed]) because the latter allows going from |
Alrighty, just pushed that! |
@enoonan looks like a small credo issue. You can add |
Added! |
Contributor checklist
Updated
AshStateMachine.Verifiers.VerifyTransitionActions
to allowcreate
transition actions whenupsert? true
is set.Added tests and added
consolidate_protocols: Mix.env() != :test
toAshStateMachine.MixProject.project
to avoid some unnecessary compiler warnings when testing.